1. Field of the Invention
The present invention relates to an image processing apparatus and a control method therefor, and, more particularly, relates to an image processing apparatus for processing a captured image and a control method therefor.
2. Description of the Related Art
A solid-state image sensor such as a CCD has several million or more pixels, and it is therefore difficult to eliminate pixels from which normal output signals cannot be obtained (defective pixels). However, since output signals from the defective pixels cannot be used as they are, defective pixel correction, in which predicted values obtained from output signals of peripheral normal pixels are used as the output signals of those defective pixels, is performed (Japanese Patent Laid-Open No. 11-220661).
Although various methods for obtaining a predicted value (pixel correction value) from output signals of peripheral normal pixels are known, a typical one will be described here. FIG. 11A is a diagram showing a part of the pixels in an image sensor having a so-called Bayer-pattern primary color filter, in which red (R) pixels, green (G) pixels, and blue (B) pixels are regularly arranged; the red pixel R33 at the center is assumed to be a defective pixel.
First, absolute differences are found between the output values of pixel pairs located in the vertical direction, the horizontal direction, the 45-degree direction, and the 135-degree direction respectively relative to the defective pixel among the peripheral pixels (B22, G23, B24, G34, B44, G43, B42, and G32) of the defective pixel. Specifically, suppose the absolute difference for the horizontal direction is H_DIV, the absolute difference for the vertical direction is V_DIV, the absolute difference for the 45-degree direction is D45_DIV, and the absolute difference for the 135-degree direction is D135_DIV. Then, the following are calculated:H_DIV=ABS(G32-G34)V_DIV=ABS(G23-G43)D45_DIV=ABS(B24-B42)D135_DIV=ABS(B22-B44)Then, the direction of the smallest absolute difference is determined to be the direction in which pixels highly correlated with the pixel of interest exist. An average value of the output values of a pair of the pixels of the same color as the defective pixel, which are located to sandwich the defective pixel in the determined direction, is used as a pixel correction value for the defective pixel.
That is, suppose the pixel correction value is Pix, and then:    If H_DIV is the smallest: Pix=(R31+R35)/2    If V_DIV is the smallest: Pix=(R13+R53)/2    If D45_DIV is the smallest: Pix=(R15+R51)/2    If D135_DIV is the smallest: Pix=(R11+R55)/2
However, a problem arises with this method in that the color of a subject significantly affects the accuracy of direction determination. For example, in the above-described example, direction determination is performed by using a difference (D45_DIV, D135_DIV) between output values of blue pixels and a difference (H_DIV, V_DIV) between output values of green pixels. In this case, if the subject is red, almost no output value is obtained from blue pixels, and therefore an error may occur in direction determination, and as a result, a problem of reduced accuracy of pixel correction values arises. The same problem occurs if direction determination is performed by using output values of red pixels and green pixels when the subject is blue.